<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Studying;
use App\Models\ActivityUserStatistics;
class AwardUserCourse extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'award:user_course';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '课程赠送修复';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $activeUsers = ActivityUserStatistics::where('invite_num', '>=',3)->get();
//        dd($activeUsers);
        foreach($activeUsers as $user){
            //满3个人赠送课程
//            dd($user->user_id);
            $studying = new Studying();
            $course_class_ids = array(8,9,31);
            foreach($course_class_ids as $course_class_id){
                $studying->addOne($user->user_id, $course_class_id);
            }
        }
        $this->info('处理完成');
    }
}
